


namespace Profit.Controls
{
    using System.Windows.Controls;
    using System.Windows;

    public sealed class SliderEx : Slider
    {
        public static readonly DependencyProperty CanIncreaseProperty = DependencyProperty.Register("CanIncrease", typeof(bool), typeof(SliderEx), new FrameworkPropertyMetadata((bool)false));
        public static readonly DependencyProperty CanDecreaseProperty = DependencyProperty.Register("CanDecrease", typeof(bool), typeof(SliderEx), new FrameworkPropertyMetadata((bool)false));

        protected override void OnValueChanged(double oldValue, double newValue)
        {
            base.OnValueChanged(oldValue, newValue);
            
            SetValue(CanIncreaseProperty,newValue < Maximum);
            SetValue(CanDecreaseProperty,newValue > Minimum);
        }

        public bool CanIncrease
        {
            get { return (bool) GetValue(CanIncreaseProperty); }
            set { SetValue(CanIncreaseProperty,value); }
        }

        public bool CanDecrease
        {
            get { return (bool)GetValue(CanDecreaseProperty); }
            set { SetValue(CanDecreaseProperty, value); }
        }
    }
}